/*
 * @Author: zhuzhaofeng
 * @Date: 2020-05-08 21:56:36
 */
// 分页器默认参数
export const pagingConfig = {
  attrs: {
    small: false,
    background: false,
    pageSize: 10,
    total: 0,
    pageCount: undefined,
    pagerCount: undefined,
    currentPage: 1,
    layout: "prev, pager, next, jumper, sizes,total",
    pageSizes: [10, 20, 30, 40, 50, 100],
    popperClass: "",
    prevText: undefined,
    nextText: undefined,
    disabled: false,
    hideOnSinglePage: undefined,
    // 对齐方式 'left', 'center', 'right'
    align: "center",
  },
  events: {
    sizeChange: () => {},
    currentChange: () => {},
    prevClick: () => {},
    nextClick: () => {},
  },
};

/**
 * 合并分页参数
 * @param { Object } props 传入的配置参数
 * @param { 'attrs' | 'events' } type 类型 attrs: '合并属性', events: 合并事件
 */
export function mergePagingArguments(props, type) {
  let obj = {};
  for (const key in pagingConfig[type]) {
    obj[key] = Object.prototype.hasOwnProperty.call(props, key)
      ? props[key]
      : pagingConfig[type][key];
  }
  return obj;
}
